package counter.ejb;
import java.util.logging.Logger;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class LogInterceptor {
    private static final Logger logger = Logger.getLogger(
            "counter.ejb. LogInterceptor");
    @AroundInvoke
    public Object log(InvocationContext ctx)
            throws Exception {

        try {
            logger.info("internalMethod: Invoking method: "
                    + ctx.getMethod().getName());
            Object result = ctx.proceed();
            logger.info("internalMethod: Returned from method: "
                    + ctx.getMethod().getName());
            return result;
        } catch (Exception e) {
            logger.warning("Error calling ctx.proceed in log()");

            return null;
        }
    }
}
